<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="format-detection" content="telephone=no" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
		<script src="../../script/mui.min.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/swiper-3.4.2.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/exam.css">
		<title>签到进行中</title>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			html {
				font-size: 10px;
			}
			#question_div {
				min-height: 400px;
			}
			.weui_mask {
				position: fixed;
				z-index: 998;
				top: 0;
				right: 0;
				bottom: 0;
				left: 0;
			}
			.weui_dialog {
				z-index: 999;
			}
			.swiper-wrapper {
				min-height: 40rem
			}
			.close_sign_div {
				/*background: #18b4ed;*/
				color: #FFF;
				height: 45px;
			}
			.close_sign_div a {
				line-height: 45px;
				font-size: 14px;
				background: #18b4ed;
				width: 100%;
				color: #FFF;
			}
			/*.close_sign_div a:active {
			 background: #FF9900;
			 }*/
			.top_sign_info_div {
				margin-top: 20px;
				text-align: center
			}
			.center_sign_img_div {
				/*height: 180px;*/
				text-align: center;
			}
			.center_sign_img_div img {
				height: 15em;
				width: 80%;
			}
			.bottom_sign_num_div {
				text-align: center;
				margin-top: 20px
			}
			input[class=now] {
				width: 2.8em;
				height: 2.8em;
				line-height: 2em;
				text-align: center;
				border: 1px #cccccc solid;
			}
			.btndiv {
				margin: 0 5%;
				margin-top: 10%;
			}
		</style>
	</head>
	<body >
		<div class="base_style_color" id='BarAppearance' style="height: 22px;width: 100%; position:fixed; left: 0px;top:0px;z-index: 998" ></div>
		<div class="base_navigation_bar base_style_color base_navigation_item_bar" style="position: fixed;left: 0px;top: 20px;">
			<a class="base_left_item" href="#" onclick="backToast()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
			<span id="title">签到进行中</span>
		</div>
		<div class="stu-test " id="content_div" style="display: none">
			<div class="ReviewWeekly_div  " style="margin-top: 64px"></div>
			<div class="space10"></div>
			<div class="k-con test-m-bottom70 test-analysis" id="question_div">
				<div class="top_sign_info_div">
					<span> 签到二维码</span>
				</div>
				<div class="center_sign_img_div">
					<img class="center_sign_img"  id="qrode_image" src="http://base.cfnet.org.cn/static/qrcode/sign_1776_1.png?code=4508" alt="" />
				</div>
				<div class="bottom_sign_num_div">
					<div class="btndiv" >
						<input type='tel' name='code[]' class='now' value="1" maxlength="1"  disabled="true"/>
						<input type='tel' name='code[]' class='now' value="1" maxlength="1"  disabled="true"/>
						<input type='tel' name='code[]' class='now'value="1" maxlength="1"  disabled="true"/>
						<input type='tel' name='code[]' class='now' value="1" maxlength="1"  disabled="true"/>
					</div>
				</div>
			</div>
			<div class="k-text-center k-fixed-bottom test-bottom1 close_sign_div" id="sub_div" onclick="closeSignToast()">
				<a>结束签到</a>
			</div>
		</div>
		<div class="noSign" hidden="hidden"  id="noData">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button"  onclick="loadData()"class="mui-btn mui-btn-outlined">
				重新加载
			</button>
		</div>
		<div id="backAlert" class="weui_dialog_confirm" style="display: none">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="checkNum"></strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a  href="#" class="weui_btn_dialog default" id="closeTest_no" style="color:#18b4ed">取消</a>
					<a  href="#" class="weui_btn_dialog primary" id="closeTest_yes" style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/timeStampTool.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript">
		var popu_type = "";
		//弹出框状态，0是正常退出，1是结束签到退出
		var timer;
		apiready = function() {
			showProgress();
			loadData();
			timer = setInterval(function() {
				loadData();
			}, 60000*5);
			btnClick();
			keyback();
			sendBuriedNotifi('0', '老师端签到进行中页', '196')
		};
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}
		//按钮点击事件
		function btnClick() {
			//正常情况下是否退出当前考试按钮取消键
			$('#closeTest_no').click(function() {
				$('#backAlert').hide();
			});
			//正常情况下是否退出当前考试按钮确定键
			$('#closeTest_yes').click(function() {
				$('#backAlert').hide();
				if (popu_type == 0) {
					JudgeTypeBack()
				} else {
					PostcloseSign();
				}
			});
		}

		//根据状态返回相应的页面
		function JudgeTypeBack() {
		    sendBuriedNotifi('1', '老师端签到进行中页', '196')
			if (api.pageParam.islist) {
				api.closeToWin({
					name : 'TeacherSignMangeWin'
				});
			} else {
				api.closeToWin({
					name : 'TeacherSignMangeWin'
				});
			}
		}

		//加载数据
		function loadData() {
			var params = {
				tid : 1,
				iid : api.pageParam.id,
				jid : $api.getStorage('cfnetppjxid'),
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
			}
			//			var url_getSignQrcodeActive = 'http://base.cfnet.org.cn/index.php/active/Interaction/getSignQrcodeActive'
			cfnetppPOST(url_getSignQrcodeActive, params, true, function(data, status) {
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						if (!isObjectEmpty(data.data)) {
							$('#content_div').show();
							setUI(data.data)
						} else {
							$('#noData').show();
							$('#noNet').hide();
							$('#content_div').hide();
						}
					} else {
						$('#noData').show();
						$('#noNet').hide();
						$('#content_div').hide();
					}
				} else {
					$('#noData').hide();
					$('#noNet').show();
					$('#content_div').hide();
				}
			})
		}

		//请求接口关闭此签到活动
		function PostcloseSign() {
			var params = {
				tid : 1,
				iid : api.pageParam.id,
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				action : 'end',
			}
			//			var url_dosign = 'http://base.cfnet.org.cn/index.php/active/interaction/dosign'
			cfnetppPOST(url_actionDosign, params, true, function(data, status) {
			SendBusinessOperationsLogNotifi('老师端签到结束 ', '196', params, params, '', data, '老师端签到结束接口', '196-01')
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						api.sendEvent({
							name : 'reloadDataList'
						});
						api.openWin({useWKWebView:true,
							name : 'TeacherSignDetailWindow',
							url : 'TeacherSignDetailWindow.html',
							pageParam : {
								type : 1,
								id : api.pageParam.id,
								item : api.pageParam.item,
								cid : api.pageParam.cid,
								pid : api.pageParam.pid,
							},
						});
					} else {
						ShowToast('关闭失败');
					}
				} else {
					ShowToast('关闭失败');
				}
			})
		}

		//设置数据
		function setUI(data) {
			var element = document.getElementById('qrode_image');
			element.src = data.path_filename;
			setInputCode(data.sign_qrcode);
		}

		//设置数字验证码
		function setInputCode(num) {
			var input = document.getElementsByTagName('input');
			for (var i = 0; i < input.length; i++) {
				input[i].value = parseInt((num / Math.pow(10, (3 - i))) % 10);
			}
		}

		//安卓系统返回键监听
		function keyback() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				backToast()
			});
		}

		//结束签到
		function closeSignToast() {
			$('#backAlert').show();
			$('#checkNum').text('是否关闭此次签到？');
			popu_type = 1;
			if (popu_type == 1) {
				//去掉定时器的方法
				clearInterval(timer);
			}
		}

		function backToast() {
			//			$('#backAlert').show();
			//			$('#checkNum').text('是否退出此次签到？');
			//			popu_type = 0;
			JudgeTypeBack();
		}
	</script>
</html>